local old = 0
local res = {}
local jsonTemp = {}
local stock = 0

for i=1, #KEYS do
	jsonTemp = {}
	old = redis.call("HGET", KEYS[i], "stock")
	stock = redis.call("HINCRBY", KEYS[i], "stock", ARGV[i])
	redis.call("HINCRBY", KEYS[i], "increase", ARGV[i])
	
	jsonTemp["key"] = KEYS[i]
	jsonTemp["old"] = old
	jsonTemp["stock"] = stock
	jsonTemp["num"] = ARGV[i]
	res[i] = jsonTemp
end

return cjson.encode(res)
